{% load auth_extras %} {# Load custom template tags if you create them #}
<!DOCTYPE html>
<html>
  <head>
    <title>{% block title %}青少年社交网络可视化分析系统{% endblock %}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link href="/static/libs/tablers/tabler.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css" />
    <style>
      body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        background-color: #f5f7fb;
        opacity: 0.1;
      }

      .navbar .navbar-nav .nav-link {
        padding-left: 16px;
        padding-right: 16px;
      }
      .content {
        flex: 1;
      }

      .page-wrapper {
        overflow-y: auto;
        overflow-x: hidden;
      }

      .page-body {
        padding-top: 20px;
        box-sizing: border-box;
        margin-top: 0 !important;
      }

      .container-xl {
        width: 100% !important;
        height: 100% !important;
      }

      .dashboard-title {
        margin-bottom: 1.5rem;
        text-align: center;
        font-weight: 600;
        color: #1e293b;
      }

      .dashboard-subtitle {
        font-size: 1rem;
        color: #64748b;
        text-align: center;
        margin-bottom: 2rem;
      }

      .stat-card {
        background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
        height: 100%;
      }

      .stat-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
      }

      .stat-card .card-body {
        padding: 1.5rem;
      }

      .stat-value {
        font-size: 2.5rem;
        font-weight: 700;
        color: #334155;
      }

      .stat-label {
        font-size: 1rem;
        color: #64748b;
        margin-top: 0.5rem;
      }

      .chart-card {
        background: #ffffff;
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        margin-bottom: 24px;
        position: relative;
        overflow: hidden;
      }

      .chart-card::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 4px;
        background: linear-gradient(90deg, #4338ca, #6366f1, #8b5cf6);
      }

      .chart-card-header {
        padding: 1rem 1.5rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

      .chart-card-header h3 {
        margin: 0;
        font-size: 1.25rem;
        font-weight: 600;
        color: #1e293b;
      }

      .chart-card-body {
        padding: 1rem;
      }

      /* 自定义仪表板样式 */
      .dashboard-header {
        background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
        color: white;
        padding: 2rem;
        border-radius: 12px;
        margin-bottom: 2rem;
        box-shadow: 0 10px 15px rgba(37, 99, 235, 0.2);
      }

      .dashboard-icon {
        font-size: 3rem;
        margin-bottom: 1rem;
      }

      /* 适配移动端 */
      @media (max-width: 768px) {
        .stat-value {
          font-size: 1.75rem;
        }

        .dashboard-header {
          padding: 1rem;
        }
      }
    </style>
    {% block extra_css %}{% endblock %}
    <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.0/dist/echarts.min.js"></script>
  </head>
  <body>
    <div class="page">
      <header class="navbar navbar-expand-md d-print-none">
        <div class="container-xl">
          <!-- BEGIN NAVBAR LOGO -->
          <div class="navbar-brand navbar-brand-autodark d-none-navbar-horizontal pe-0 pe-md-3">
            <a href="/">青少年社交网络可视化分析系统</a>
          </div>
          <!-- END NAVBAR LOGO -->
          <div class="navbar-nav flex-row order-md-last">
            {% if request.user.is_authenticated %}
            <div class="nav-item dropdown">
              <a href="#" class="nav-link d-flex lh-1 p-0 px-2" data-bs-toggle="dropdown" aria-label="Open user menu">
                <span class="avatar avatar-sm" style="background-image: url(./static/avatars/000m.jpg)"> </span>
                <div class="d-none d-xl-block ps-2">
                  <div class="mt-1 small text-secondary">{{ request.user.username }}</div>
                </div>
              </a>
              <div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow">
                <div class="dropdown-divider"></div>
                <a href="/logout/" class="dropdown-item">退出登录</a>
              </div>
            </div>
            {% endif %}
          </div>
        </div>
      </header>
      {% if request.user.is_authenticated %}
      <header class="navbar-expand-md">
        <div class="collapse navbar-collapse" id="navbar-menu">
          <div class="navbar">
            <div class="container-xl">
              <div class="row flex-column flex-md-row flex-fill align-items-center">
                <div class="col">
                  <!-- BEGIN NAVBAR MENU -->
                  <ul class="navbar-nav">
                    <!-- 首页 -->
                    <li class="nav-item {% if navname == 'home' %}active{% endif %}">
                      <a class="nav-link" href="/">
                        <span class="nav-link-icon d-md-none d-lg-inline-block"
                          ><!-- Download SVG icon from http://tabler.io/icons/icon/home -->
                          <svg
                            xmlns="http://www.w3.org/2000/svg"
                            width="24"
                            height="24"
                            viewBox="0 0 24 24"
                            fill="none"
                            stroke="currentColor"
                            stroke-width="2"
                            stroke-linecap="round"
                            stroke-linejoin="round"
                            class="icon icon-1"
                          >
                            <path d="M5 12l-2 0l9 -9l9 9l-2 0" />
                            <path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" />
                            <path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" /></svg
                        ></span>
                        <span class="nav-link-title"> 首页 </span>
                      </a>
                    </li>
                    {% if request.user.is_superuser %}
                    <!-- 数据管理 -->
                    <li class="nav-item">
                      <a class="nav-link" href="/supper/data/">
                        <span class="nav-link-title"> 数据管理 </span>
                      </a>
                    </li>
                    <li class="nav-item">
                      <a class="nav-link" href="/supper/users/">
                        <span class="nav-link-title"> 用户管理 </span>
                      </a>
                    </li>
                    {% endif %} {% if not request.user.is_superuser %}
                    <!-- 基本数据分析 -->
                    <li class="nav-item {% if navname == 'basic' %}active{% endif %}">
                      <a class="nav-link" href="/analysis/basic/">
                        <span class="nav-link-title"> 基本数据分析 </span>
                      </a>
                    </li>
                    <!-- 数据分析 -->
                    {% comment %} 如果 navname 为 "interests", 添加 active class {% endcomment %}
                    <li class="nav-item {% if navname == 'interests' %}active{% endif %}">
                      <a class="nav-link" href="/analysis/interests/">
                        <span class="nav-link-title"> 体育活动分析 </span>
                      </a>
                    </li>
                    <!-- 音乐喜好分析 -->
                    <li class="nav-item {% if navname == 'music' %}active{% endif %}">
                      <a class="nav-link" href="/analysis/personality/">
                        <span class="nav-link-title"> 音乐喜好分析 </span>
                      </a>
                    </li>
                    <!-- 宗教信仰分析 -->
                    <li class="nav-item {% if navname == 'religious' %}active{% endif %}">
                      <a class="nav-link" href="/analysis/religious/">
                        <span class="nav-link-title"> 宗教信仰分析 </span>
                      </a>
                    </li>
                    <!-- 时尚偏好分析 -->
                    <li class="nav-item {% if navname == 'fashion' %}active{% endif %}">
                      <a class="nav-link" href="/analysis/fashion/">
                        <span class="nav-link-title"> 时尚偏好分析 </span>
                      </a>
                    </li>
                    <li class="nav-item {% if navname == 'risk' %}active{% endif %}">
                      <a class="nav-link" href="/analysis/risk/">
                        <span class="nav-link-title"> 风险行为分析 </span>
                      </a>
                    </li>
                    <!-- 如果 navname 为 "correlation", 添加 active class -->
                    <li class="nav-item {% if navname == 'correlation' %}active{% endif %}">
                      <a class="nav-link" href="/analysis/correlation/">
                        <span class="nav-link-title"> 相关性分析 </span>
                      </a>
                    </li>
                    {% endif %}
                  </ul>
                  <!-- END NAVBAR MENU -->
                </div>
                <div class="col col-md-auto">
                  <ul class="navbar-nav">
                    <li class="nav-item">
                      <a class="nav-link" href="#" data-bs-toggle="offcanvas" data-bs-target="#offcanvasSettings">
                        <span class="badge badge-sm bg-red text-red-fg">New</span>
                        <span class="nav-link-icon d-md-none d-lg-inline-block">
                          <!-- Download SVG icon from http://tabler.io/icons/icon/settings -->
                          <svg
                            xmlns="http://www.w3.org/2000/svg"
                            width="24"
                            height="24"
                            viewBox="0 0 24 24"
                            fill="none"
                            stroke="currentColor"
                            stroke-width="2"
                            stroke-linecap="round"
                            stroke-linejoin="round"
                            class="icon icon-1"
                          >
                            <path
                              d="M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z"
                            />
                            <path d="M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" />
                          </svg>
                        </span>
                        <span class="nav-link-title"> 设置 </span>
                      </a>
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </div>
        </div>
      </header>
      {% endif %}
      <div class="page-wrapper">
        <div class="page-body">
          <div class="container-fluid">
            {% if messages %} {% for message in messages %}
            <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert">
              <div>{{ message }}</div>
              <a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
            </div>
            {% endfor %} {% endif %}
            <!-- 基本统计卡片 -->
            <div class="row mb-4" id="survey-data">
              <div class="col-md-6 col-lg-3 mb-3">
                <div class="stat-card">
                  <div class="card-body">
                    <div class="d-flex align-items-center">
                      <div class="bg-primary bg-opacity-10 p-3 rounded-3">
                        <i class="ti ti-users text-primary" style="font-size: 2rem"></i>
                      </div>
                      <div class="ms-3">
                        <div class="stat-value">{{ basic_info.total_surveys }}</div>
                        <div class="stat-label">总调查人数</div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

              <div class="col-md-6 col-lg-3 mb-3">
                <div class="stat-card">
                  <div class="card-body">
                    <div class="d-flex align-items-center">
                      <div class="bg-info bg-opacity-10 p-3 rounded-3">
                        <i class="ti ti-user text-info" style="font-size: 2rem"></i>
                      </div>
                      <div class="ms-3">
                        <div class="stat-value">{{ basic_info.avg_age }}</div>
                        <div class="stat-label">平均年龄</div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

              <div class="col-md-6 col-lg-3 mb-3">
                <div class="stat-card">
                  <div class="card-body">
                    <div class="d-flex align-items-center">
                      <div class="bg-success bg-opacity-10 p-3 rounded-3">
                        <i class="ti ti-friends text-success" style="font-size: 2rem"></i>
                      </div>
                      <div class="ms-3">
                        <div class="stat-value">{{ basic_info.avg_friends }}</div>
                        <div class="stat-label">平均朋友数量</div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

              <div class="col-md-6 col-lg-3 mb-3">
                <div class="stat-card">
                  <div class="card-body">
                    <div class="d-flex align-items-center">
                      <div class="bg-warning bg-opacity-10 p-3 rounded-3">
                        <i class="ti ti-gender-bigender text-warning" style="font-size: 2rem"></i>
                      </div>
                      <div class="ms-3">
                        <div class="stat-value">{{ basic_info.male_count }}/{{ basic_info.female_count }}</div>
                        <div class="stat-label">男/女比例</div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <!-- 第一行图表 -->
            <div class="row mb-4">
              <div class="col-md-4 mb-4">
                <div class="chart-card h-100">
                  <div class="chart-card-header">
                    <h3>性别分布</h3>
                    <span class="badge bg-primary">基础数据</span>
                  </div>
                  <div class="chart-card-body">{{ charts.gender_pie|safe }}</div>
                </div>
              </div>

              <div class="col-md-8 mb-4">
                <div class="chart-card h-100">
                  <div class="chart-card-header">
                    <h3>体育活动兴趣雷达图</h3>
                    <span class="badge bg-info">运动偏好</span>
                  </div>
                  <div class="chart-card-body">{{ charts.sports_radar|safe }}</div>
                </div>
              </div>
            </div>

            <!-- 第二行图表 -->
            <div class="row mb-4">
              <div class="col-md-6 mb-4">
                <div class="chart-card h-100">
                  <div class="chart-card-header">
                    <h3>音乐艺术兴趣分布</h3>
                    <span class="badge bg-success">艺术偏好</span>
                  </div>
                  <div class="chart-card-body">{{ charts.music_bar|safe }}</div>
                </div>
              </div>

              <div class="col-md-6 mb-4">
                <div class="chart-card h-100">
                  <div class="chart-card-header">
                    <h3>宗教信仰指标</h3>
                    <span class="badge bg-warning">信仰分析</span>
                  </div>
                  <div class="chart-card-body">{{ charts.religion_pie|safe }}</div>
                </div>
              </div>
            </div>

            <!-- 第三行图表 -->
            <div class="row mb-4">
              <div class="col-md-8 mb-4">
                <div class="chart-card h-100">
                  <div class="chart-card-header">
                    <h3>时尚与外表关注度</h3>
                    <span class="badge bg-purple">时尚偏好</span>
                  </div>
                  <div class="chart-card-body">{{ charts.fashion_bar|safe }}</div>
                </div>
              </div>

              <div class="col-md-4 mb-4">
                <div class="chart-card h-100">
                  <div class="chart-card-header">
                    <h3>个性特征评分</h3>
                    <span class="badge bg-teal">特征指标</span>
                  </div>
                  <div class="chart-card-body">{{ charts.personality_scatter|safe }}</div>
                </div>
              </div>
            </div>

            <!-- 第四行图表 -->
            <div class="row mb-4">
              <div class="col-md-6 mb-4">
                <div class="chart-card h-100">
                  <div class="chart-card-header">
                    <h3>风险行为评分</h3>
                    <span class="badge bg-danger">风险分析</span>
                  </div>
                  <div class="chart-card-body">{{ charts.risk_line|safe }}</div>
                </div>
              </div>

              <div class="col-md-6 mb-4">
                <div class="chart-card h-100">
                  <div class="chart-card-header">
                    <h3>年龄与朋友数量关系</h3>
                    <span class="badge bg-azure">相关性</span>
                  </div>
                  <div class="chart-card-body">{{ charts.age_friends_scatter|safe }}</div>
                </div>
              </div>
            </div>
            <!-- 结束仪表板内容 -->
          </div>
        </div>
      </div>
    </div>

    <script src="/static/libs/tablers/tabler.min.js"></script>
  </body>
</html>
